Fix fallback menubar size allocation
authorMatthias Clasen <mclasen@redhat.com>
Sat, 16 Nov 2013 19:49:21 +0000 (14:49 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 16 Nov 2013 19:52:26 +0000 (14:52 -0500)
When the menubar inserted by GtkApplicationWindow is the widest
widget in a csd window, its allocation gets cut short. Fix this
by taking the decoration size into account while calculating
the size request (it is implicitly taken into account in the
size allocation phase by _gtk_window_set_allocation).

gtk/gtkapplicationwindow.c

index 9c3d1ba36f2f8879fac9d91e3abfc538a8f96a26..079f4bbdb2ebff52e7cf94286f6294d33537435f 100644 (file)
@@ -547,8 +547,17 @@ gtk_application_window_real_get_preferred_width (GtkWidget *widget,
   if (window->priv->menubar != NULL)
     {
       gint menubar_min_width, menubar_nat_width;
+      gint border_width;
+      GtkBorder border = { 0 };
 
       gtk_widget_get_preferred_width (window->priv->menubar, &menubar_min_width, &menubar_nat_width);
+
+      border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+      _gtk_window_get_decoration_size (GTK_WINDOW (widget), &border);
+
+      menubar_min_width += 2 * border_width + border.left + border.right;
+      menubar_nat_width += 2 * border_width + border.left + border.right;
+
       *minimum_width = MAX (*minimum_width, menubar_min_width);
       *natural_width = MAX (*natural_width, menubar_nat_width);
     }
@@ -574,8 +583,17 @@ gtk_application_window_real_get_preferred_width_for_height (GtkWidget *widget,
   if (window->priv->menubar != NULL)
     {
       gint menubar_min_width, menubar_nat_width;
+      gint border_width;
+      GtkBorder border = { 0 };
 
       gtk_widget_get_preferred_width_for_height (window->priv->menubar, menubar_height, &menubar_min_width, &menubar_nat_width);
+
+      border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
+      _gtk_window_get_decoration_size (GTK_WINDOW (widget), &border);
+
+      menubar_min_width += 2 * border_width + border.left + border.right;
+      menubar_nat_width += 2 * border_width + border.left + border.right;
+
       *minimum_width = MAX (*minimum_width, menubar_min_width);
       *natural_width = MAX (*natural_width, menubar_nat_width);
     }